package com.cx.afc_android.widget;

import android.view.View;
import android.widget.TextView;

import com.cx.afc_android.R;
import com.cx.afc_android.common.MyDialogFragment;
import com.hjq.base.BaseDialog;

import androidx.annotation.StringRes;
import androidx.fragment.app.FragmentActivity;

/**
 * Created by chenxiang on 2019/9/25.
 */

public class WaitDialog {
    public static final class Builder
            extends MyDialogFragment.Builder<Builder> {

        private final TextView mMessageView;

        public Builder(FragmentActivity activity) {
            super(activity);
            setContentView(R.layout.dialog_wait);
            setAnimStyle(BaseDialog.AnimStyle.TOAST);
            setBackgroundDimEnabled(false);
            setCancelable(false);

            mMessageView = findViewById(R.id.tv_wait_message);
        }

        public Builder setMessage(@StringRes int id) {
            return setMessage(getString(id));
        }
        public Builder setMessage(CharSequence text) {
            mMessageView.setText(text);
            mMessageView.setVisibility(text == null ? View.GONE : View.VISIBLE);
            return this;
        }
    }
}
